//
//  MerchantMapController.swift
//  ExpressManager
//
//  Created by yongkang on 2017/11/6.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit
import GoogleMaps
import MapKit
import CoreLocation

class MerchantMapController: UIViewController {
    
    
    
    var mainMapView: MKMapView!
    let locationManager:CLLocationManager = CLLocationManager()
    
    @IBOutlet weak var googleMapView: GMSMapView!
    
    
//    lazy var mapView: MKMapView = {
//        let mapView = MKMapView(frame: UIScreen.main.bounds)
//        //用户位置追踪(用户位置追踪用于标记用户当前位置，此时会调用定位服务)
//        mapView.userTrackingMode = .follow
//        //地图的显示风格，此处设置使用标准地图
//        mapView.mapType = .standard
//        //地图是否可滚动，默认为true
//        mapView.isScrollEnabled = true
//        //地图是否缩放，默认为true
//        mapView.isZoomEnabled = true
//        //是否显示用户当前位置 ios8之后才有，默认为false
//        mapView.showsUserLocation = true
//        //为MKMapView设置delegate
//        mapView.delegate = self as! MKMapViewDelegate
//        
//        return mapView
//    }()
    
    
    
    

    override func viewDidLoad() {
        super.viewDidLoad()
        //view.addSubview(self.mapView)

        self.mainMapView = MKMapView(frame:self.view.frame)
        self.view.addSubview(self.mainMapView)
        
        self.mainMapView.mapType = MKMapType.standard
        
        let latDelta = 0.05
        let longDelta = 0.05
        let currentLocationSpan:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
        
        
        let center:CLLocation = CLLocation(latitude: 32.029171, longitude: 118.788231)
        let currentRegion:MKCoordinateRegion = MKCoordinateRegion(center: center.coordinate,
                                                                  span: currentLocationSpan)
        
        
        self.mainMapView.setRegion(currentRegion, animated: true)
        
        let objectAnnotation = MKPointAnnotation()
        
        objectAnnotation.coordinate = CLLocation(latitude: 32.029171,
                                                longitude: 118.788231).coordinate
        
        objectAnnotation.title = "南京夫子庙"
        //设置点击大头针之后显示的描述
        objectAnnotation.subtitle = "南京市秦淮区秦淮河北岸中华路"
        //添加大头针
        self.mainMapView.addAnnotation(objectAnnotation)
    }
    
    
    
    func setUI() {
        
        
//        self.googleMapView.snp.makeConstraints { (make) in
//            make.top.equalTo(10)
//            make.left.equalTo(10)
//            make.height.equalTo(200)
//            make.right.equalTo(-10)
//        }
        
        
        
        let camera = GMSCameraPosition.camera(withLatitude:1.285, longitude:103.848, zoom:12)
        let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
        mapView.isMyLocationEnabled = true
        mapView.mapType = kGMSTypeSatellite
        googleMapView = mapView;
        
        
        let marker = GMSMarker()
        marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
        marker.title = "Sydney"
        marker.snippet = "Australia"
        marker.map = mapView
        
        
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
